package org.gap.service;

import java.util.Calendar;
import java.util.List;
import java.util.Set;

import org.gap.domain.Adherent;
import org.gap.domain.CaractPM;
import org.gap.domain.CaractPP;
import org.gap.domain.Patient;
import org.gap.domain.RelationsTiers;
import org.gap.domain.RolesTiers;
import org.gap.domain.Tiers;
import org.gap.domain.TiersModif;
import org.gap.domain.Utilisateurs;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class TiersServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected TiersService service;

	/**
	 * Instantiates a new TiersServiceTest.
	 *
	 */
	public TiersServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Load an existing Tiers entity
	 * 
	 */
	@Test
	public void loadTierss() {
		Set<Tiers> response = null;
		response = service.loadTierss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadTierss
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findTiersByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findTiersByPrimaryKey 
		Integer tieTiers = 0;
		Tiers response = null;
		response = service.findTiersByPrimaryKey(tieTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: findTiersByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Save an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void saveTiersUtilisateurses() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersUtilisateurses 
		Integer tieTiers_1 = 0;
		Utilisateurs related_utilisateurses = new org.gap.domain.Utilisateurs();
		Tiers response = null;
		response = service.saveTiersUtilisateurses(tieTiers_1, related_utilisateurses);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersUtilisateurses
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Tiers entity
	 * 
	 */
	@Test
	public void countTierss() {
		Integer response = null;
		response = service.countTierss();
		// TODO: JUnit - Add assertions to test outputs of operation: countTierss
	}

	/**
	 * Operation Unit Test
	 * Save an existing CaractPM entity
	 * 
	 */
	@Test
	public void saveTiersCaractPM() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersCaractPM 
		Integer tieTiers_2 = 0;
		CaractPM related_caractpm = new org.gap.domain.CaractPM();
		Tiers response = null;
		response = service.saveTiersCaractPM(tieTiers_2, related_caractpm);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersCaractPM
	}

	/**
	 * Operation Unit Test
	 * Delete an existing RelationsTiers entity
	 * 
	 */
	@Test
	public void deleteTiersRelationsTiersesForRltTiersFils() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersRelationsTiersesForRltTiersFils 
		Integer tiers_tieTiers = 0;
		Integer related_relationstiersesforrlttiersfils_rltTiersParent = 0;
		Integer related_relationstiersesforrlttiersfils_rltTiersFils = 0;
		String related_relationstiersesforrlttiersfils_rltRelation = null;
		Tiers response = null;
		response = service.deleteTiersRelationsTiersesForRltTiersFils(tiers_tieTiers, related_relationstiersesforrlttiersfils_rltTiersParent, related_relationstiersesforrlttiersfils_rltTiersFils, related_relationstiersesforrlttiersfils_rltRelation);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersRelationsTiersesForRltTiersFils
	}

	/**
	 * Operation Unit Test
	 * Save an existing CaractPP entity
	 * 
	 */
	@Test
	public void saveTiersCaractPP() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersCaractPP 
		Integer tieTiers_3 = 0;
		CaractPP related_caractpp = new org.gap.domain.CaractPP();
		Tiers response = null;
		response = service.saveTiersCaractPP(tieTiers_3, related_caractpp);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersCaractPP
	}

	/**
	 * Operation Unit Test
	 * Save an existing TiersModif entity
	 * 
	 */
	@Test
	public void saveTiersTiersModifs() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersTiersModifs 
		Integer tieTiers_4 = 0;
		TiersModif related_tiersmodifs = new org.gap.domain.TiersModif();
		Tiers response = null;
		response = service.saveTiersTiersModifs(tieTiers_4, related_tiersmodifs);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersTiersModifs
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Adherent entity
	 * 
	 */
	@Test
	public void deleteTiersAdherents() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersAdherents 
		Integer tiers_tieTiers_1 = 0;
		Integer related_adherents_adhId = 0;
		Tiers response = null;
		response = service.deleteTiersAdherents(tiers_tieTiers_1, related_adherents_adhId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersAdherents
	}

	/**
	 * Operation Unit Test
	 * Save an existing RelationsTiers entity
	 * 
	 */
	@Test
	public void saveTiersRelationsTiersesForRltTiersFils() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersRelationsTiersesForRltTiersFils 
		Integer tieTiers_5 = 0;
		RelationsTiers related_relationstiersesforrlttiersfils = new org.gap.domain.RelationsTiers();
		Tiers response = null;
		response = service.saveTiersRelationsTiersesForRltTiersFils(tieTiers_5, related_relationstiersesforrlttiersfils);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersRelationsTiersesForRltTiersFils
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Tiers entity
	 * 
	 */
	@Test
	public void deleteTiers() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiers 
		Tiers tiers = new org.gap.domain.Tiers();
		service.deleteTiers(tiers);
	}

	/**
	 * Operation Unit Test
	 * Save an existing Patient entity
	 * 
	 */
	@Test
	public void saveTiersPatients() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersPatients 
		Integer tieTiers_6 = 0;
		Patient related_patients = new org.gap.domain.Patient();
		Tiers response = null;
		response = service.saveTiersPatients(tieTiers_6, related_patients);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersPatients
	}

	/**
	 * Operation Unit Test
	 * Return all Tiers entity
	 * 
	 */
	@Test
	public void findAllTierss() {
		// TODO: JUnit - Populate test inputs for operation: findAllTierss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Tiers> response = null;
		response = service.findAllTierss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllTierss
	}

	/**
	 * Operation Unit Test
	 * Delete an existing RolesTiers entity
	 * 
	 */
	@Test
	public void deleteTiersRolesTierses() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersRolesTierses 
		Integer tiers_tieTiers_2 = 0;
		String related_rolestierses_rotRole = null;
		Integer related_rolestierses_rotTiers = 0;
		Tiers response = null;
		response = service.deleteTiersRolesTierses(tiers_tieTiers_2, related_rolestierses_rotRole, related_rolestierses_rotTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersRolesTierses
	}

	/**
	 * Operation Unit Test
	 * Delete an existing RelationsTiers entity
	 * 
	 */
	@Test
	public void deleteTiersRelationsTiersesForRltTiersParent() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersRelationsTiersesForRltTiersParent 
		Integer tiers_tieTiers_3 = 0;
		Integer related_relationstiersesforrlttiersparent_rltTiersParent = 0;
		Integer related_relationstiersesforrlttiersparent_rltTiersFils = 0;
		String related_relationstiersesforrlttiersparent_rltRelation = null;
		Tiers response = null;
		response = service.deleteTiersRelationsTiersesForRltTiersParent(tiers_tieTiers_3, related_relationstiersesforrlttiersparent_rltTiersParent, related_relationstiersesforrlttiersparent_rltTiersFils, related_relationstiersesforrlttiersparent_rltRelation);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersRelationsTiersesForRltTiersParent
	}

	/**
	 * Operation Unit Test
	 * Save an existing RelationsTiers entity
	 * 
	 */
	@Test
	public void saveTiersRelationsTiersesForRltTiersParent() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersRelationsTiersesForRltTiersParent 
		Integer tieTiers_7 = 0;
		RelationsTiers related_relationstiersesforrlttiersparent = new org.gap.domain.RelationsTiers();
		Tiers response = null;
		response = service.saveTiersRelationsTiersesForRltTiersParent(tieTiers_7, related_relationstiersesforrlttiersparent);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersRelationsTiersesForRltTiersParent
	}

	/**
	 * Operation Unit Test
	 * Save an existing Tiers entity
	 * 
	 */
	@Test
	public void saveTiers() {
		// TODO: JUnit - Populate test inputs for operation: saveTiers 
		Tiers tiers_1 = new org.gap.domain.Tiers();
		service.saveTiers(tiers_1);
	}

	/**
	 * Operation Unit Test
	 * Delete an existing TiersModif entity
	 * 
	 */
	@Test
	public void deleteTiersTiersModifs() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersTiersModifs 
		Integer tiers_tieTiers_4 = 0;
		Integer related_tiersmodifs_tmoTiers = 0;
		String related_tiersmodifs_tmoNomChampModif = null;
		Calendar related_tiersmodifs_tmoDateModification = null;
		Tiers response = null;
		response = service.deleteTiersTiersModifs(tiers_tieTiers_4, related_tiersmodifs_tmoTiers, related_tiersmodifs_tmoNomChampModif, related_tiersmodifs_tmoDateModification);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersTiersModifs
	}

	/**
	 * Operation Unit Test
	 * Save an existing RolesTiers entity
	 * 
	 */
	@Test
	public void saveTiersRolesTierses() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersRolesTierses 
		Integer tieTiers_8 = 0;
		RolesTiers related_rolestierses = new org.gap.domain.RolesTiers();
		Tiers response = null;
		response = service.saveTiersRolesTierses(tieTiers_8, related_rolestierses);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersRolesTierses
	}

	/**
	 * Operation Unit Test
	 * Delete an existing CaractPP entity
	 * 
	 */
	@Test
	public void deleteTiersCaractPP() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersCaractPP 
		Integer tiers_tieTiers_5 = 0;
		Integer related_caractpp_cppTiers = 0;
		Tiers response = null;
		response = service.deleteTiersCaractPP(tiers_tieTiers_5, related_caractpp_cppTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersCaractPP
	}

	/**
	 * Operation Unit Test
	 * Save an existing Adherent entity
	 * 
	 */
	@Test
	public void saveTiersAdherents() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersAdherents 
		Integer tieTiers_9 = 0;
		Adherent related_adherents = new org.gap.domain.Adherent();
		Tiers response = null;
		response = service.saveTiersAdherents(tieTiers_9, related_adherents);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersAdherents
	}

	/**
	 * Operation Unit Test
	 * Delete an existing CaractPM entity
	 * 
	 */
	@Test
	public void deleteTiersCaractPM() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersCaractPM 
		Integer tiers_tieTiers_6 = 0;
		Integer related_caractpm_cpmTiers = 0;
		Tiers response = null;
		response = service.deleteTiersCaractPM(tiers_tieTiers_6, related_caractpm_cpmTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersCaractPM
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void deleteTiersUtilisateurses() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersUtilisateurses 
		Integer tiers_tieTiers_7 = 0;
		String related_utilisateurses_usrUser = null;
		Tiers response = null;
		response = service.deleteTiersUtilisateurses(tiers_tieTiers_7, related_utilisateurses_usrUser);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersUtilisateurses
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Patient entity
	 * 
	 */
	@Test
	public void deleteTiersPatients() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersPatients 
		Integer tiers_tieTiers_8 = 0;
		Integer related_patients_patPatient = 0;
		Tiers response = null;
		response = service.deleteTiersPatients(tiers_tieTiers_8, related_patients_patPatient);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersPatients
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
